
from selenium.common.exceptions import *
class LOGIN():

    def  __init__(self,driver):
        self.driver = driver

    def URL(self,url):
        return self.driver.get(url)

    def element(self,*loc):
        try:
            self.driver.find_element(*loc)
            print("%s 定位成功")
            return self.driver.find_element(*loc)
        except NoSuchElementException as N:
            print("%s 定位失败")

    def send_key(self,loc):
        try:
            self.element().send_keys(loc)
            print("%s 数据发送成功" % loc)
            return self.element().send_keys(loc)
        except Exception as E:
            print("%s数据发送失败"% E)

    def click(self):
        try:
            self.element().click()
            print("点击成功")
            return self.element().click()
        except Exception as E:
            print("点击失败")

    def clear(self):
        try:
            self.element().clear()
            print("清空成功")
            return self.element().clear()
        except Exception as E:
            print("清空失败")

    def quit(self):
        return self.driver.quit()

    def implicitly_wait(self):
        return self.driver.implicitly_wait(10)

    def maximize_window(self):
        return self.driver.maximize_window()


